import {Injectable} from "@angular/core";
import {TestData} from "@shared/utils/TestData";
import {PageService} from "@core/service/page/PageService";
import {DiskService} from "@core/service/DiskService";
import {UserActionService} from "@core/service/UserActionService";
import {NzMessageService} from "ng-zorro-antd/message";
import {Router} from "@angular/router";
import {NzContextMenuService} from "ng-zorro-antd/dropdown";
import {NzModalService} from "ng-zorro-antd/modal";
import {FileUploadService} from "@core/service/FileUploadService";
import {NzImageService} from "ng-zorro-antd/image";
import {ClipboardService} from "@core/service/ClipboardService";
import {BBYUtils} from "@shared/utils/BBYUtils";
import {AuthService} from "@core/service/AuthService";

@Injectable({
  providedIn: 'root',
})
export class ClassifyPageService extends PageService{
  category:'image'|'text'|'video'|'audio'|'zip'="image"
  constructor(
    protected authService: AuthService,
    protected diskService: DiskService,
    protected userActionService:UserActionService,
    protected message: NzMessageService,
    protected router: Router,
    protected nzContextMenuService: NzContextMenuService,
    protected dialogService: NzModalService,
    protected fileUploadService: FileUploadService,
    protected nzImageService: NzImageService,
    protected clipboardService: ClipboardService
  ) {
    super(
      diskService, userActionService, message, router,
      nzContextMenuService, dialogService, fileUploadService,
      nzImageService, clipboardService);
    this.pageStatus.owner = {
      userId: authService.getUserInfo()?.userId || '',
      username: authService.getUserInfo()?.username || '全部文件',
      self:true
    }
  }
  loadCategory(category:any){
    this.pageStatus.flash()
    this.rootUrl='myDisk'
    this.category=category
    this.pageStatus.loading=true
    BBYUtils.handelResult(
      this.diskService.classify(category),
      res => {
        console.log('loadCategory',res)
        this.dealFileList(res.data)
        this.pageStatus.fileList = res.data;

        this.pageStatus.loading=false
      },
      res => {
        this.message.error(res.msg)
        this.pageStatus.loading=false
      }
    )
    // this.pageStatus.fileList=TestData.root

    console.log('category==',category)
  }
}
